*********************************************************************************
/*    Create scatter plot of MVPF estimates, by income		*/
*********************************************************************************
* File paths
local datapath "${mvpf_audits}/data/cleaned" 
local datafolder "${mvpf_audits}/data/outside" 
local graphpath "${graphpath}" 

* Version of fig to produce 
global version  ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

use "${mvpf_audits}/data/figures_rep/figure_9.dta", clear

tw  (scatter mvpf tpi_pctl, mc(gs11) msymbol(T) msize(vsmall)) ///
	(rspike l_mvpf u_mvpf inc_pctl_2020, lc(gs6) lw(thin)) ///
	(scatter mvpf inc_pctl_2020 if ~missing(inc_pctl_2020), mc(gs6) msymbol(S) msize(`symbsize')) ///
	///(scatter mvpf inc_pctl_2020, mlab(small_label_name) $labs msym(none) mlabpos(3) mlabsize(2)) ///
	(rspike mvpf_h mvpf_l decile, lc("${rc_col}") lw(thin)) ///
	(scatter mvpf decile, mc("${rc_col}") msymbol(O) msize(medsmall)) ///
	///(scatter mvpf5 xaxis2, mc("${rc_col}") msymbol(Oh) msize(medsmall)) ///
	, ///
	ylab(0.5 "<0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2+", nogrid) ///
	ytitle("`ylab'") xtitle("Income Percentile")   ///
	${title} ${axis_size} ///
	xlabel(0(10)100,  nogrid) xscale(r(0 105)) ///
	///legend(order(7 6) ring(0) pos(5) col(3) lab(6 "winsorized") lab(7 "5X")) ///
	legend(off)
graph export "`graphpath'/scatter_mvpf_tpi_det.wmf", as(wmf) replace

	
if "${version}" == "slides"{
	* Tax audits only
	tw  (scatter mvpf tpi_pctl, mc(white) msymbol(T) msize(vsmall)) ///
		(rspike l_mvpf u_mvpf inc_pctl_2020, lc(white) lw(thin)) ///
		(scatter mvpf inc_pctl_2020 if ~missing(inc_pctl_2020), mc(white) msymbol(S) msize(`symbsize')) ///
		(rspike mvpf_h mvpf_l decile, lc("${rc_col}") lw(thin)) ///
		(scatter mvpf decile, mc("${rc_col}") msymbol(O) msize(medsmall)) ///
		, ///
		ylab(0.5 "<0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2+", nogrid) ///
		ytitle("`ylab'") xtitle("Income Percentile")   ///
		${title} ${axis_size} ///
		xlabel(0(10)100,  nogrid) xscale(r(0 105)) ///
		///legend(order(7 6) ring(0) pos(5) col(3) lab(6 "winsorized") lab(7 "5X")) ///
		legend(off)
graph export "`graphpath'/animations/scatter_mvpf_tpi_det_audits.wmf", as(wmf) replace	

* Tax audits plus aax rates
	tw  (rspike l_mvpf u_mvpf inc_pctl_2020, lc(white) lw(thin)) ///
		(scatter mvpf inc_pctl_2020 if ~missing(inc_pctl_2020), mc(white) msymbol(S) msize(`symbsize')) ///
		(rspike mvpf_h mvpf_l decile, lc("${rc_col}") lw(thin)) ///
		(scatter mvpf decile, mc("${rc_col}") msymbol(O) msize(medsmall)) ///
		(scatter mvpf tpi_pctl, mc(gs11) msymbol(T) msize(vsmall)) ///
		, ///
		ylab(0.5 "<0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2+", nogrid) ///
		ytitle("`ylab'") xtitle("Income Percentile")   ///
		${title} ${axis_size} ///
		xlabel(0(10)100,  nogrid) xscale(r(0 105)) ///
		///legend(order(7 6) ring(0) pos(5) col(3) lab(6 "winsorized") lab(7 "5X")) ///
		legend(off)
graph export "`graphpath'/animations/scatter_mvpf_tpi_det_audits_taxes.wmf", as(wmf) replace	
}